{% extends 'base.html' %}
{% block content%}

    {% regroup object_list by year as year_list %}
<table class="tabl_rep" style="width:700px;">
{% for w in object_list %}
    {% if forloop.first %}
    <tr class="heador"><td colspan="3" style="height:20px;">Список отпусков&nbsp;{{ w.employee }}</td></tr>
    {% endif %}
{% endfor %}
<tr><td><strong>Год</strong></td><td><strong>Отпуск 1</strong></td><td><strong>Отпуск 2</strong></td></tr>
{% for year in year_list %}


    <tr class={% cycle "color1" "color2" %}>
    <td style="height:20px;"><strong>{{ year.grouper }}</strong></td>
        {% for item in year.list %}
            <td style="height:20px;">{% if item.a_vacation1 %}{{ item.a_vacation1 }}{% endif %}</td>
            <td style="height:20px;">{% if item.a_vacation2 %}{{ item.a_vacation2 }}{% endif %}</td>
        {% endfor %}
    </tr>

{% endfor %}
</table>

{% if user.is_superuser %}
<form method="POST" action="{% url add_update emp %}">{% csrf_token %}
        <table class="forma">
            <tr>
                <td>Год:</td>
                <td>
                    <select name="year">
                    <option value=""></option>
                    {% for year in years %}
                    <option value="{{ year }}">{{ year }}</option>
                    {% endfor %}
                    </select>
                </td>
            </tr>
            <tr>
                <td>Отпуск 1:</td>
                <td>
                    <select name="vac1">
                    <option value=""></option>
                    {% for mon in m_list %}
                    <option value="{{ mon }}">{{ mon }}</option>
                    {% endfor %}
                    </select>
                </td>
            </tr>
            <tr>
                <td>Отпуск 2:</td>
                <td>
                    <select name="vac2">
                    <option value=""></option>
                    {% for mon in m_list %}
                    <option value="{{ mon }}">{{ mon }}</option>
                    {% endfor %}
                    </select>
                </td>
            </tr>
        <tr><td colspan="2"><input type="submit" value="Внести данные"/></td></tr>
        </table>
</form>
   {% endif %}
{% endblock %}